#pragma once

namespace winboost {
   namespace resources{

template<typename T>
class resource_handle
{
public:
   typedef typename T*            value_type;
   typedef boost::shared_ptr<T>   handle_type;
   typedef boost::weak_ptr<T>     weak_handle_type;

   value_type handle(void) const;

   void set_id(UINT id);
   void set_id(LPCTSTR ids);

protected:
   handle_type m_handle;

private:
   virtual void set_id_impl(LPCTSTR ids, HINSTANCE hinst){}
};

   }
}


//-------------------------------------
//  implementation
//-------------------------------------
template<typename T>
T* winboost::resources::resource_handle<T>::handle(void) const
{
   return m_handle.get();
}

template<typename T>
void winboost::resources::resource_handle<T>::set_id(UINT id)
{
   LPCTSTR ids = MAKEINTRESOURCE(id);
   set_id_impl(ids, instance_handle());
}

template<typename T>
void winboost::resources::resource_handle<T>::set_id(LPCTSTR ids)
{
   set_id_impl(ids, instance_handle());
}
